import { post, upload } from '@/libs/request'

/**
 * 上传头像
 */
const uploadAvatar = (filePath: string) =>
  upload<{
    url: string
    objectName: string
  }>({
    url: 'user/avatar/upload',
    filePath,
    name: 'file',
  })

/**
 * 获取头像链接
 */
const getAvatar = (objectName: string) =>
  post<{
    url: string
    objectName: string
  }>('user/avatar/getUrl', { objectName })

/**
 * 获取已邀请人数
 * @param sessionId 测试会话ID，两个参数传一个即可
 * @param resultId 测试结果ID，两个参数传一个即可
 */
const getInviteCount = (sessionId: string, resultId: number) =>
  post<{
    inviteCount: number
    totalCount: number
  }>('suan/result/inviteCount', { sessionId, resultId })

export { uploadAvatar, getAvatar, getInviteCount }
